<template>
  <el-header>
    <div class="header-left">
      <i class="el-icon-s-fold icon"></i>
    </div>
    <div class="header-right">
      <!-- @command：是函数，专门处理下拉框中的请求事件的  -->
      <el-dropdown @command="handleCommand" trigger="click">
        <span class="el-dropdown-link">
          <img src="../assets/logo.png" alt="" /> 你好, 张三
        </span>
        <el-dropdown-menu slot="dropdown">
          <el-dropdown-item command="userInfo">个人中心</el-dropdown-item>
          <el-dropdown-item command="editPassword">修改密码</el-dropdown-item>
          <el-dropdown-item command="system">系统设置</el-dropdown-item>
          <el-dropdown-item command="logout">退出登录</el-dropdown-item>
        </el-dropdown-menu>
      </el-dropdown>
    </div>
  </el-header>
</template>

<script scoped>
export default {
  methods: {
    // 处理顶部用户下拉框信息
    handleCommand(command) {
      //this.$message('click on item ' + command);
      if (command == "logout") {
        sessionStorage.removeItem("username");
        this.$router.push("/login");
      }
    },
  },
};
</script>

<style>
.header-left {
  float: left;
}

.header-left .icon {
  font-size: 26px;
  padding-top: 17px;
  cursor: pointer;
}

.el-dropdown-link {
  cursor: pointer;
}

.header-right {
  float: right;
  line-height: 60px;
}

.header-right img {
  height: 50px;
  vertical-align: middle;
}
</style>